import request from '@/utils/request'

export default {
    // 验证token
    checktoken(token) {
        return request.get('/userinf/verify', {
            params: {
                token
            }
        })
    },
    //查询订单
    cheackcart(user_id) {
        return request.get('/order/cartlist', {
            params: {
                user_id,
                page: 1,
                pagesize: 50
            }
        })
    },
    search(name){
       
        return request.get("/good/getpagelist",{
            params:{
                page:1,
                pagesize:100,
                opt:{
                    "name":name
                }
                
            }
        })
    },
    // 添加购物车
    addcart(user_id, num, good_id) {
        let url = `/order/add/${good_id}`
        return request.put(url, {
            user_id,
            num
        })
    },
    delgood(cart_id) {
        console.log(cart_id);
        return request.delete("/order/del", {
            data: {
                cart_id
            }
        })

    },
    // 获取商品列表
    goodlist(page) {

        return request.get('/good/goodlist', {
            params: {
                page,
                pagesize: 20
            }
        })
    },
    // 查询商品
    good(id) {
        return request.get('good/getgood', {
            params: {
                good_id: id
            }
        })
    },
    // 模糊查询商品
    getList(page, pagesize, opt) {  //当前页，一页多少条
        return request.get("/good/getpagelist", {
            params: {
                page, pagesize, opt
            }
        })
    },


}
